import cdnImport from 'vite-plugin-cdn-import'
import { viteExternalsPlugin } from 'vite-plugin-externals'
// 第三方库加载cdn， 可能需要vite-plugin-externals 配合使用 
// 'vue-router': 'VueRouter', axios: 'axios',
export default function createCdnImport(isBuild) {
    if (!isBuild) {
        return [];
    }
    return [
        viteExternalsPlugin({
            vue: 'Vue',
        }),
        cdnImport({
            modules: [
                { name: 'vue', var: 'Vue', path: 'https://cdn.jsdelivr.net/npm/vue@3.5.13/dist/vue.global.js' },
                { name: 'pinia', var: "Pinia", path: 'https://cdn.jsdelivr.net/npm/pinia@3.0.2/dist/pinia.iife.min.js' }
            ]
        })
    ]
}
